#include<stdio.h>
#include<iostream>
#include<string.h>
using namespace std;
int main()
{
    //freopen("in.txt","r",stdin);
    char s1[1000];
    char s2[1000];
    cin>>s1;
    cin>>s2;
    int len = strlen(s1);
    int ans = 1;
    for(int i = 0; i < len;i++)
    {
        for(int j = len-1; j > 0; j--)
        {
            if(s1[i] == s2[j] && s1[i+1] == s2[j-1])
            {
                ans = ans * 2;
            }
        }
    }
    printf("%d",ans);
}